package me.cjj.android.assignment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        final EditText etStudentName = findViewById(R.id.etStudentName);
        final EditText etStudentId = findViewById(R.id.etStudentId);
        findViewById(R.id.btn_start_quiz)
                .setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        if (etStudentName.getText().toString().isEmpty() || etStudentId.getText().toString().isEmpty()) {
                            Toast.makeText(v.getContext(), "Please input name and id", Toast.LENGTH_LONG).show();
                            return;
                        }
                        QuizActivity.start(v.getContext());
                    }
                });
    }
}
